package com.ttbj.controller.cutpayrevoke;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ttbj.api.cutpayrevoke.CutPayRevokeService;
import com.ttbj.api.dto.CutPayRevokeData;
import com.ttbj.api.dto.Page;
import com.ttbj.api.exception.BusinessException;
import com.ttbj.util.ViewDataUtil;



@Controller
public class CutPayRevokeController {
	
	@Autowired
	private CutPayRevokeService cutPayRevokeService;
	
	/**
	 * 分账撤销列表
	 * @return
	 */
	@RequestMapping(value="/cprevoke/cp_revoke.htm")
	public String cp_revoke() {
		return "/cprevoke/cp_revoke";
	}
	
	/**
	 * 分页条件查询分账撤销的列表
	 * @param request
	 * @param cutPayRevokeData 分账撤销查询条件
	 * @param page 分页页码
	 * @return
	 */
	@RequestMapping(value="/cprevoke/getCutPayRevokeByPage.htm", method=RequestMethod.POST, produces={"text/html;charset=UTF-8;","application/json;"})
	@ResponseBody
	public String getCutPayRevokeByPage(HttpServletRequest request, CutPayRevokeData cutPayRevokeData, Page page) {
		try {
			List<CutPayRevokeData> cutPayRevokeDatas = this.cutPayRevokeService.findCutPayRevokeByPage(cutPayRevokeData, page);
			int count = 0;
			if (cutPayRevokeDatas != null) {
				count = this.cutPayRevokeService.findCutPayRevokeByPageCount(cutPayRevokeData);
			}
			return ViewDataUtil.buildSuccessPageJson("分账撤销列表", cutPayRevokeDatas, count);
		} catch (BusinessException e) {
			return ViewDataUtil.buildFailureJson(e.getErrorCode(), e.getMessage());
		}
	}
}
